package com.cby.android.sample.repository

import com.cby.android.sample.repository.api.ApiSource
import com.cby.android.sample.repository.api.WanAndroidApiService
import com.cby.android.sample.bean.wan.*
import retrofit2.http.GET
import retrofit2.http.Path
import retrofit2.http.Query

/**
 * @description: WanAndroidRepository
 * @author: ChenBaoYang
 * @createDate: 2022/4/29 2:12 下午
 */
interface WanAndroidApi {

    suspend fun getBanners() : WanApiResponse<List<WanBannerBean>>

    suspend fun getArticles(page:Int) : WanApiResponse<WanApiPageResponse<WanArticleBean>>

    suspend fun getFriendSites() : WanApiResponse<List<WanFriendSiteBean>>

    suspend fun getHotKey() : WanApiResponse<List<WanHotKeyBean>>

    suspend fun getTopArticles() : WanApiResponse<List<WanArticleBean>>

    suspend fun getProjectClassify(): WanApiResponse<List<WanClassifyBean>>

    suspend fun getProjectList(page: Int, cid: Int): WanApiResponse<WanApiPageResponse<WanArticleBean>>
}

class WanAndroidApiImpl : WanAndroidApi{
    private val apiService : WanAndroidApiService by lazy { ApiSource.getWanAndroidService(
        WanAndroidApiService::class.java) }

    override suspend fun getBanners() = apiService.getBanners()

    override suspend fun getArticles(page: Int) = apiService.getArticles(page)

    override suspend fun getFriendSites() = apiService.getFriendSites()

    override suspend fun getHotKey() = apiService.getHotKey()

    override suspend fun getTopArticles() = apiService.getTopArticles()

    override suspend fun getProjectClassify() = apiService.getProjectClassify()

    override suspend fun getProjectList(page: Int, cid: Int) = apiService.getProjectList(page, cid)

}